package form.ui.component.Alert
{
	import flash.display.GradientType;
	
	import form.ui.Alert;
	import form.ui.core.ProgrammaticSkin;
	import form.utils.ColorUtil;

	public class AlertBackground extends ProgrammaticSkin
	{
		public var cornerRadius:Number = 5;
		public var fillAlphas:Array = [0.6, 0.4, 0.75, 0.65];
		public var fillColors:Array = [0xcccccc, 0xcccccc, 0xcccccc, 0xeeeeee];
		public var highlightAlphas:Array = [0.3, 0];	
		public var themeColor:uint = 0xCCCCCC;
		
		public function AlertBackground()
		{
			super();
			
			this.width = Alert.DEFAULT_WIDTH;
			this.height = Alert.DEFAULT_HEIGHT;
		}
		
		override protected function updateDisplayList(w:Number, h:Number):void
		{
			super.updateDisplayList(w, h);
			
			var upFillColors:Array = [ fillColors[0], fillColors[1] ];	   				
			var upFillAlphas:Array = [ fillAlphas[0], fillAlphas[1] ];
			
			var themeColorDrk1:Number =
				ColorUtil.adjustBrightness2(themeColor, -25);
			
			var cr:Number = Math.max(0, cornerRadius);
			var cr1:Number = Math.max(0, cornerRadius - 1);
			var cr2:Number = Math.max(0, cornerRadius - 2);

			// button border/edge
			drawRoundRect(
				0, 0, w, h, cr,
				[ themeColor, themeColorDrk1 ], 1,
				verticalGradientMatrix(0, 0, w, h ),
				GradientType.LINEAR, null, 
				{ x: 1, y: 1, w: w - 2, h: h - 2, r: cornerRadius - 1 });
                    
			// button fill
			drawRoundRect(
				1, 1, w - 2, h - 2, cr2,
				upFillColors, upFillAlphas,
				verticalGradientMatrix(2, 2, w - 2, h - 2));
								  
			// top highlight
			drawRoundRect(
				1, 1, w - 2, (h - 2) / 1,
				{ tl: cr2, tr: cr2, bl: 0, br: 0 },
				[ 0xFFFFFF, 0xFFFFFF ], highlightAlphas,
				verticalGradientMatrix(1, 1, w - 1, (h - 1) / 1)); 
		}
	}
}